home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / mysql-4.0.22-win / data1.cab / Development / include / my_global.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-28  |  34.7 KB  |  1,142 lines

  1. /* Copyright (C) 2000-2003 MySQL AB
  2.  
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.  
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. /* This is the include file that should be included 'first' in every C file. */
  18.  
  19. #ifndef _global_h
  20. #define _global_h
  21.  
  22. #ifndef EMBEDDED_LIBRARY
  23. #define HAVE_REPLICATION
  24. #define HAVE_EXTERNAL_CLIENT
  25. #endif
  26.  
  27. #if defined( __EMX__) && !defined( MYSQL_SERVER)
  28. /* moved here to use below VOID macro redefinition */
  29. #define INCL_BASE
  30. #define INCL_NOPMAPI
  31. #include <os2.h>
  32. #endif /* __EMX__ */
  33.  
  34. #ifdef __CYGWIN__
  35. /* We use a Unix API, so pretend it's not Windows */
  36. #undef WIN
  37. #undef WIN32
  38. #undef _WIN
  39. #undef _WIN32
  40. #undef _WIN64
  41. #undef __WIN__
  42. #undef __WIN32__
  43. #define HAVE_ERRNO_AS_DEFINE
  44. #endif /* __CYGWIN__ */
  45.  
  46. #if defined(i386) && !defined(__i386__)
  47. #define __i386__
  48. #endif
  49.  
  50. /* Macros to make switching between C and C++ mode easier */
  51. #ifdef __cplusplus
  52. #define C_MODE_START    extern "C" {
  53. #define C_MODE_END    }
  54. #else
  55. #define C_MODE_START
  56. #define C_MODE_END
  57. #endif
  58.  
  59. #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
  60. #include <config-win.h>
  61. #elif defined(OS2)
  62. #include <config-os2.h>
  63. #elif defined(__NETWARE__)
  64. #include <my_config.h>
  65. #include <config-netware.h>
  66. #if defined(__cplusplus) && defined(inline)
  67. #undef inline                /* fix configure problem */
  68. #endif
  69. #else
  70. #include <my_config.h>
  71. #if defined(__cplusplus) && defined(inline)
  72. #undef inline                /* fix configure problem */
  73. #endif
  74. #endif /* _WIN32... */
  75.  
  76. /* Some defines to avoid ifdefs in the code */
  77. #ifndef NETWARE_YIELD
  78. #define NETWARE_YIELD
  79. #define NETWARE_SET_SCREEN_MODE(A)
  80. #endif
  81.  
  82. /*
  83.   The macros below are borrowed from include/linux/compiler.h in the
  84.   Linux kernel. Use them to indicate the likelyhood of the truthfulness
  85.   of a condition. This serves two purposes - newer versions of gcc will be
  86.   able to optimize for branch predication, which could yield siginficant
  87.   performance gains in frequently executed sections of the code, and the
  88.   other reason to use them is for documentation
  89. */
  90.  
  91. #if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
  92. #define __builtin_expect(x, expected_value) (x)
  93. #endif
  94.  
  95. #define likely(x)    __builtin_expect((x),1)
  96. #define unlikely(x)    __builtin_expect((x),0)
  97.  
  98.  
  99. /* Fix problem with S_ISLNK() on Linux */
  100. #if defined(HAVE_LINUXTHREADS)
  101. #undef  _GNU_SOURCE
  102. #define _GNU_SOURCE 1
  103. #endif
  104.  
  105. /* The client defines this to avoid all thread code */
  106. #if defined(UNDEF_THREADS_HACK)
  107. #undef THREAD
  108. #undef HAVE_mit_thread
  109. #undef HAVE_LINUXTHREADS
  110. #undef HAVE_UNIXWARE7_THREADS
  111. #endif
  112.  
  113. #ifdef HAVE_THREADS_WITHOUT_SOCKETS
  114. /* MIT pthreads does not work with unix sockets */
  115. #undef HAVE_SYS_UN_H
  116. #endif
  117.  
  118. #define __EXTENSIONS__ 1    /* We want some extension */
  119. #ifndef __STDC_EXT__
  120. #define __STDC_EXT__ 1          /* To get large file support on hpux */
  121. #endif
  122.  
  123. #if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
  124. #ifndef _POSIX_PTHREAD_SEMANTICS
  125. #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
  126. #endif
  127.  
  128. #if !defined(SCO)
  129. #define _REENTRANT    1    /* Some thread libraries require this */
  130. #endif
  131. #if !defined(_THREAD_SAFE) && !defined(_AIX)
  132. #define _THREAD_SAFE            /* Required for OSF1 */
  133. #endif
  134. #ifndef HAVE_mit_thread
  135. #ifdef HAVE_UNIXWARE7_THREADS
  136. #include <thread.h>
  137. #else
  138. #include <pthread.h>        /* AIX must have this included first */
  139. #endif /* HAVE_UNIXWARE7_THREADS */
  140. #endif /* HAVE_mit_thread */
  141. #if !defined(SCO) && !defined(_REENTRANT)
  142. #define _REENTRANT    1    /* Threads requires reentrant code */
  143. #endif
  144. #endif /* THREAD */
  145.  
  146. /* Go around some bugs in different OS and compilers */
  147. #ifdef _AIX            /* By soren@t.dk */
  148. #define _H_STRINGS
  149. #define _SYS_STREAM_H
  150. /* #define _AIX32_CURSES */    /* XXX: this breaks AIX 4.3.3 (others?). */
  151. #define ulonglong2double(A) my_ulonglong2double(A)
  152. #define my_off_t2double(A)  my_ulonglong2double(A)
  153. C_MODE_START
  154. double my_ulonglong2double(unsigned long long A);
  155. C_MODE_END
  156. #endif /* _AIX */
  157.  
  158. #ifdef HAVE_BROKEN_SNPRINTF    /* HPUX 10.20 don't have this defined */
  159. #undef HAVE_SNPRINTF
  160. #endif
  161. #ifdef HAVE_BROKEN_PREAD
  162. /*
  163.   pread()/pwrite() are not 64 bit safe on HP-UX 11.0 without
  164.   installing the kernel patch PHKL_20349 or greater
  165. */
  166. #undef HAVE_PREAD
  167. #undef HAVE_PWRITE
  168. #endif
  169. #if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
  170. #undef inline
  171. #define inline
  172. #endif
  173.  
  174. #ifdef UNDEF_HAVE_GETHOSTBYNAME_R        /* For OSF4.x */
  175. #undef HAVE_GETHOSTBYNAME_R
  176. #endif
  177. #ifdef UNDEF_HAVE_INITGROUPS            /* For AIX 4.3 */
  178. #undef HAVE_INITGROUPS
  179. #endif
  180.  
  181. /* gcc/egcs issues */
  182.  
  183. #if defined(__GNUC) && defined(__EXCEPTIONS)
  184. #error "Please add -fno-exceptions to CXXFLAGS and reconfigure/recompile"
  185. #endif
  186.  
  187.  
  188. /* Fix a bug in gcc 2.8.0 on IRIX 6.2 */
  189. #if SIZEOF_LONG == 4 && defined(__LONG_MAX__)
  190. #undef __LONG_MAX__             /* Is a longlong value in gcc 2.8.0 ??? */
  191. #define __LONG_MAX__ 2147483647
  192. #endif
  193.  
  194. /* Fix problem when linking c++ programs with gcc 3.x */
  195. #ifdef DEFINE_CXA_PURE_VIRTUAL
  196. #define FIX_GCC_LINKING_PROBLEM extern "C" { int __cxa_pure_virtual() {return 0;} }
  197. #else
  198. #define FIX_GCC_LINKING_PROBLEM
  199. #endif
  200.  
  201. /* egcs 1.1.2 has a problem with memcpy on Alpha */
  202. #if defined(__GNUC__) && defined(__alpha__) && ! (__GNUC__ > 2 || (__GNUC__ == 2 &&  __GNUC_MINOR__ >= 95))
  203. #define BAD_MEMCPY
  204. #endif
  205.  
  206. /* In Linux-alpha we have atomic.h if we are using gcc */
  207. #if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 &&  __GNUC_MINOR__ >= 95)) && !defined(HAVE_ATOMIC_ADD)
  208. #define HAVE_ATOMIC_ADD
  209. #define HAVE_ATOMIC_SUB
  210. #endif
  211.  
  212. /* In Linux-ia64 including atomic.h will give us an error */
  213. #if (defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && (defined(__ia64__)||defined(__powerpc64__))) || !defined(THREAD)
  214. #undef HAVE_ATOMIC_ADD
  215. #undef HAVE_ATOMIC_SUB
  216. #endif
  217.  
  218. #if defined(_lint) && !defined(lint)
  219. #define lint
  220. #endif
  221. #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
  222. #define _LONG_LONG 1        /* For AIX string library */
  223. #endif
  224.  
  225. #ifndef stdin
  226. #include <stdio.h>
  227. #endif
  228. #ifdef HAVE_STDLIB_H
  229. #include <stdlib.h>
  230. #endif
  231. #ifdef HAVE_STDDEF_H
  232. #include <stddef.h>
  233. #endif
  234.  
  235. #include <math.h>
  236. #ifdef HAVE_LIMITS_H
  237. #include <limits.h>
  238. #endif
  239. #ifdef HAVE_FLOAT_H
  240. #include <float.h>
  241. #endif
  242.  
  243. #ifdef HAVE_SYS_TYPES_H
  244. #include <sys/types.h>
  245. #endif
  246. #ifdef HAVE_FCNTL_H
  247. #include <fcntl.h>
  248. #endif
  249. #ifdef HAVE_SYS_TIMEB_H
  250. #include <sys/timeb.h>                /* Avoid warnings on SCO */
  251. #endif
  252. #if TIME_WITH_SYS_TIME
  253. # include <sys/time.h>
  254. # include <time.h>
  255. #else
  256. # if HAVE_SYS_TIME_H
  257. #  include <sys/time.h>
  258. # else
  259. #  include <time.h>
  260. # endif
  261. #endif /* TIME_WITH_SYS_TIME */
  262. #ifdef HAVE_UNISTD_H
  263. #if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
  264. #define crypt unistd_crypt
  265. #endif
  266. #include <unistd.h>
  267. #ifdef HAVE_OPENSSL
  268. #undef crypt
  269. #endif
  270. #endif
  271. #if defined(__cplusplus) && defined(NO_CPLUSPLUS_ALLOCA)
  272. #undef HAVE_ALLOCA
  273. #undef HAVE_ALLOCA_H
  274. #endif
  275. #ifdef HAVE_ALLOCA_H
  276. #include <alloca.h>
  277. #endif
  278. #ifdef HAVE_ATOMIC_ADD
  279. #define __SMP__
  280. #ifdef HAVE_LINUX_CONFIG_H
  281. #include <linux/config.h>    /* May define CONFIG_SMP */
  282. #endif
  283. #ifndef CONFIG_SMP
  284. #define CONFIG_SMP
  285. #endif
  286. C_MODE_START
  287. #include <asm/atomic.h>
  288. C_MODE_END
  289. #endif
  290. #include <errno.h>                /* Recommended by debian */
  291. /* We need the following to go around a problem with openssl on solaris */
  292. #if defined(HAVE_CRYPT_H)
  293. #include <crypt.h>
  294. #endif
  295.  
  296. /* Go around some bugs in different OS and compilers */
  297. #if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
  298. #include <sys/stream.h>        /* HPUX 10.20 defines ulong here. UGLY !!! */
  299. #define HAVE_ULONG
  300. #endif
  301. #ifdef DONT_USE_FINITE        /* HPUX 11.x has is_finite() */
  302. #undef HAVE_FINITE
  303. #endif
  304. #if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)
  305. /* Fix bug in setrlimit */
  306. #undef setrlimit
  307. #define setrlimit cma_setrlimit64
  308. #endif
  309.  
  310. #ifdef __QNXNTO__
  311. /* This has to be after include limits.h */
  312. #define HAVE_ERRNO_AS_DEFINE
  313. #define HAVE_FCNTL_LOCK
  314. #undef  HAVE_FINITE
  315. #undef  LONGLONG_MIN            /* These get wrongly defined in QNX 6.2 */
  316. #undef  LONGLONG_MAX            /* standard system library 'limits.h' */
  317. #endif
  318.  
  319. /* We can not live without the following defines */
  320.  
  321. #define USE_MYFUNC 1        /* Must use syscall indirection */
  322. #define MASTER 1        /* Compile without unireg */
  323. #define ENGLISH 1        /* Messages in English */
  324. #define POSIX_MISTAKE 1        /* regexp: Fix stupid spec error */
  325. #define USE_REGEX 1        /* We want the use the regex library */
  326. /* Do not define for ultra sparcs */
  327. #ifndef OS2
  328. #define USE_BMOVE512 1        /* Use this unless system bmove is faster */
  329. #endif
  330.  
  331. #define QUOTE_ARG(x)        #x    /* Quote argument (before cpp) */
  332. #define STRINGIFY_ARG(x) QUOTE_ARG(x)    /* Quote argument, after cpp */
  333.  
  334. /* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
  335. #ifdef I_AM_PARANOID
  336. #define DONT_ALLOW_USER_CHANGE 1
  337. #define DONT_USE_MYSQL_PWD 1
  338. #endif
  339.  
  340. /* Does the system remember a signal handler after a signal ? */
  341. #ifndef HAVE_BSD_SIGNALS
  342. #define DONT_REMEMBER_SIGNAL
  343. #endif
  344.  
  345. /* Define void to stop lint from generating "null effekt" comments */
  346. #ifndef DONT_DEFINE_VOID
  347. #ifdef _lint
  348. int    __void__;
  349. #define VOID(X)        (__void__ = (int) (X))
  350. #else
  351. #undef VOID
  352. #define VOID(X)        (X)
  353. #endif
  354. #endif /* DONT_DEFINE_VOID */
  355.  
  356. #if defined(_lint) || defined(FORCE_INIT_OF_VARS)
  357. #define LINT_INIT(var)    var=0            /* No uninitialize-warning */
  358. #else
  359. #define LINT_INIT(var)
  360. #endif
  361.  
  362. /* Define some useful general macros */
  363. #if defined(__cplusplus) && defined(__GNUC__)
  364. #define max(a, b)    ((a) >? (b))
  365. #define min(a, b)    ((a) <? (b))
  366. #elif !defined(max)
  367. #define max(a, b)    ((a) > (b) ? (a) : (b))
  368. #define min(a, b)    ((a) < (b) ? (a) : (b))
  369. #endif
  370.  
  371. #if defined(__EMX__) || !defined(HAVE_UINT)
  372. typedef unsigned int uint;
  373. typedef unsigned short ushort;
  374. #endif
  375.  
  376. #define CMP_NUM(a,b)    (((a) < (b)) ? -1 : ((a) == (b)) ? 0 : 1)
  377. #define sgn(a)        (((a) < 0) ? -1 : ((a) > 0) ? 1 : 0)
  378. #define swap(t,a,b)    { register t dummy; dummy = a; a = b; b = dummy; }
  379. #define test(a)        ((a) ? 1 : 0)
  380. #define set_if_bigger(a,b)  { if ((a) < (b)) (a)=(b); }
  381. #define set_if_smaller(a,b) { if ((a) > (b)) (a)=(b); }
  382. #define test_all_bits(a,b) (((a) & (b)) == (b))
  383. #define set_bits(type, bit_count) (sizeof(type)*8 <= (bit_count) ? ~(type) 0 : ((((type) 1) << (bit_count)) - (type) 1))
  384. #define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
  385. #ifndef HAVE_RINT
  386. #define rint(A) floor((A)+(((A) < 0)? -0.5 : 0.5))
  387. #endif
  388.  
  389. /* Define some general constants */
  390. #ifndef TRUE
  391. #define TRUE        (1)    /* Logical true */
  392. #define FALSE        (0)    /* Logical false */
  393. #endif
  394.  
  395. #if defined(__GNUC__)
  396. #define function_volatile    volatile
  397. #define my_reinterpret_cast(A) reinterpret_cast<A>
  398. #define my_const_cast(A) const_cast<A>
  399. #elif !defined(my_reinterpret_cast)
  400. #define my_reinterpret_cast(A) (A)
  401. #define my_const_cast(A) (A)
  402. #endif
  403. #if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__)  || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
  404. #define __attribute__(A)
  405. #endif
  406.  
  407. /* From old s-system.h */
  408.  
  409. /*
  410.   Support macros for non ansi & other old compilers. Since such
  411.   things are no longer supported we do nothing. We keep then since
  412.   some of our code may still be needed to upgrade old customers.
  413. */
  414. #define _VARARGS(X) X
  415. #define _STATIC_VARARGS(X) X
  416. #define _PC(X)    X
  417.  
  418. #if defined(DBUG_ON) && defined(DBUG_OFF)
  419. #undef DBUG_OFF
  420. #endif
  421.  
  422. #if defined(_lint) && !defined(DBUG_OFF)
  423. #define DBUG_OFF
  424. #endif
  425.  
  426. #include <my_dbug.h>
  427.  
  428. #define MIN_ARRAY_SIZE    0    /* Zero or One. Gcc allows zero*/
  429. #define ASCII_BITS_USED 8    /* Bit char used */
  430. #define NEAR_F            /* No near function handling */
  431.  
  432. /* Some types that is different between systems */
  433.  
  434. typedef int    File;        /* File descriptor */
  435. #ifndef Socket_defined
  436. typedef int    my_socket;    /* File descriptor for sockets */
  437. #define INVALID_SOCKET -1
  438. #endif
  439. /* Type for fuctions that handles signals */
  440. #define sig_handler RETSIGTYPE
  441. C_MODE_START
  442. typedef void    (*sig_return)();/* Returns type from signal */
  443. C_MODE_END
  444. #if defined(__GNUC__) && !defined(_lint)
  445. typedef char    pchar;        /* Mixed prototypes can take char */
  446. typedef char    puchar;        /* Mixed prototypes can take char */
  447. typedef char    pbool;        /* Mixed prototypes can take char */
  448. typedef short    pshort;        /* Mixed prototypes can take short int */
  449. typedef float    pfloat;        /* Mixed prototypes can take float */
  450. #else
  451. typedef int    pchar;        /* Mixed prototypes can't take char */
  452. typedef uint    puchar;        /* Mixed prototypes can't take char */
  453. typedef int    pbool;        /* Mixed prototypes can't take char */
  454. typedef int    pshort;        /* Mixed prototypes can't take short int */
  455. typedef double    pfloat;        /* Mixed prototypes can't take float */
  456. #endif
  457. C_MODE_START
  458. typedef int    (*qsort_cmp)(const void *,const void *);
  459. typedef int    (*qsort_cmp2)(void*, const void *,const void *);
  460. C_MODE_END
  461. #ifdef HAVE_mit_thread
  462. #define qsort_t void
  463. #undef QSORT_TYPE_IS_VOID
  464. #define QSORT_TYPE_IS_VOID
  465. #else
  466. #define qsort_t RETQSORTTYPE    /* Broken GCC cant handle typedef !!!! */
  467. #endif
  468. #ifdef HAVE_mit_thread
  469. #define size_socket socklen_t    /* Type of last arg to accept */
  470. #else
  471. #ifdef HAVE_SYS_SOCKET_H
  472. #include <sys/socket.h>
  473. #endif
  474. typedef SOCKET_SIZE_TYPE size_socket;
  475. #endif
  476.  
  477. #ifndef SOCKOPT_OPTLEN_TYPE
  478. #define SOCKOPT_OPTLEN_TYPE size_socket
  479. #endif
  480.  
  481. /* file create flags */
  482.  
  483. #ifndef O_SHARE            /* Probably not windows */
  484. #define O_SHARE        0    /* Flag to my_open for shared files */
  485. #ifndef O_BINARY
  486. #define O_BINARY    0    /* Flag to my_open for binary files */
  487. #endif
  488. #ifndef FILE_BINARY
  489. #define FILE_BINARY    O_BINARY /* Flag to my_fopen for binary streams */
  490. #endif
  491. #ifdef HAVE_FCNTL
  492. #define HAVE_FCNTL_LOCK
  493. #define F_TO_EOF    0L    /* Param to lockf() to lock rest of file */
  494. #endif
  495. #endif /* O_SHARE */
  496.  
  497. #ifndef O_TEMPORARY
  498. #define O_TEMPORARY    0
  499. #endif
  500. #ifndef O_SHORT_LIVED
  501. #define O_SHORT_LIVED    0
  502. #endif
  503.  
  504. /* #define USE_RECORD_LOCK    */
  505.  
  506.     /* Unsigned types supported by the compiler */
  507. #define UNSINT8            /* unsigned int8 (char) */
  508. #define UNSINT16        /* unsigned int16 */
  509. #define UNSINT32        /* unsigned int32 */
  510.  
  511.     /* General constants */
  512. #define SC_MAXWIDTH    256    /* Max width of screen (for error messages) */
  513. #define FN_LEN        256    /* Max file name len */
  514. #define FN_HEADLEN    253    /* Max length of filepart of file name */
  515. #define FN_EXTLEN    20    /* Max length of extension (part of FN_LEN) */
  516. #define FN_REFLEN    512    /* Max length of full path-name */
  517. #define FN_EXTCHAR    '.'
  518. #define FN_HOMELIB    '~'    /* ~/ is used as abbrev for home dir */
  519. #define FN_CURLIB    '.'    /* ./ is used as abbrev for current dir */
  520. #define FN_PARENTDIR    ".."    /* Parentdirectory; Must be a string */
  521. #define FN_DEVCHAR    ':'
  522.  
  523. #ifndef FN_LIBCHAR
  524. #ifdef __EMX__
  525. #define FN_LIBCHAR    '\\'
  526. #define FN_ROOTDIR    "\\"
  527. #else
  528. #define FN_LIBCHAR    '/'
  529. #define FN_ROOTDIR    "/"
  530. #endif
  531. #define MY_NFILE    1024    /* This is only used to save filenames */
  532. #endif
  533.  
  534. /* #define EXT_IN_LIBNAME     */
  535. /* #define FN_NO_CASE_SENCE   */
  536. /* #define FN_UPPER_CASE TRUE */
  537.  
  538. /*
  539.   Io buffer size; Must be a power of 2 and a multiple of 512. May be
  540.   smaller what the disk page size. This influences the speed of the
  541.   isam btree library. eg to big to slow.
  542. */
  543. #define IO_SIZE            4096
  544. /*
  545.   How much overhead does malloc have. The code often allocates
  546.   something like 1024-MALLOC_OVERHEAD bytes
  547. */
  548. #ifdef SAFEMALLOC
  549. #define MALLOC_OVERHEAD (8+24+4)
  550. #else
  551. #define MALLOC_OVERHEAD 8
  552. #endif
  553.     /* get memory in huncs */
  554. #define ONCE_ALLOC_INIT        (uint) (4096-MALLOC_OVERHEAD)
  555.     /* Typical record cash */
  556. #define RECORD_CACHE_SIZE    (uint) (64*1024-MALLOC_OVERHEAD)
  557.     /* Typical key cash */
  558. #define KEY_CACHE_SIZE        (uint) (8*1024*1024-MALLOC_OVERHEAD)
  559.  
  560.     /* Some things that this system doesn't have */
  561.  
  562. #define NO_HASH            /* Not needed anymore */
  563. #ifdef __WIN__
  564. #define NO_DIR_LIBRARY        /* Not standar dir-library */
  565. #define USE_MY_STAT_STRUCT    /* For my_lib */
  566. #endif
  567.  
  568. /* Some things that this system does have */
  569.  
  570. #ifndef HAVE_ITOA
  571. #define USE_MY_ITOA        /* There is no itoa */
  572. #endif
  573.  
  574. /* Some defines of functions for portability */
  575.  
  576. #ifndef HAVE_ATOD
  577. #define atod        atof
  578. #endif
  579. #ifdef USE_MY_ATOF
  580. #define atof        my_atof
  581. extern void        init_my_atof(void);
  582. extern double        my_atof(const char*);
  583. #endif
  584. #undef remove        /* Crashes MySQL on SCO 5.0.0 */
  585. #ifndef __WIN__
  586. #ifdef OS2
  587. #define closesocket(A)    soclose(A)
  588. #else
  589. #define closesocket(A)    close(A)
  590. #endif
  591. #ifndef ulonglong2double
  592. #define ulonglong2double(A) ((double) (ulonglong) (A))
  593. #define my_off_t2double(A)  ((double) (my_off_t) (A))
  594. #endif
  595. #endif
  596.  
  597. #ifndef offsetof
  598. #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
  599. #endif
  600. #define ulong_to_double(X) ((double) (ulong) (X))
  601. #define SET_STACK_SIZE(X)    /* Not needed on real machines */
  602.  
  603. #if !defined(HAVE_mit_thread) && !defined(HAVE_STRTOK_R)
  604. #define strtok_r(A,B,C) strtok((A),(B))
  605. #endif
  606.  
  607. /* Remove some things that mit_thread break or doesn't support */
  608. #if defined(HAVE_mit_thread) && defined(THREAD)
  609. #undef HAVE_PREAD
  610. #undef HAVE_REALPATH
  611. #undef HAVE_MLOCK
  612. #undef HAVE_TEMPNAM                /* Use ours */
  613. #undef HAVE_PTHREAD_SETPRIO
  614. #undef HAVE_FTRUNCATE
  615. #undef HAVE_READLINK
  616. #endif
  617.  
  618. /* This is from the old m-machine.h file */
  619.  
  620. #if SIZEOF_LONG_LONG > 4
  621. #define HAVE_LONG_LONG 1
  622. #endif
  623.  
  624. /*
  625.   Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define
  626.   ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined.
  627.   Also on Windows we define these constants by hand in config-win.h.
  628. */
  629.  
  630. #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN)
  631. #define LONGLONG_MIN    ((long long) 0x8000000000000000LL)
  632. #define LONGLONG_MAX    ((long long) 0x7FFFFFFFFFFFFFFFLL)
  633. #endif
  634.  
  635. #if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)
  636. /* First check for ANSI C99 definition: */
  637. #ifdef ULLONG_MAX
  638. #define ULONGLONG_MAX  ULLONG_MAX
  639. #else
  640. #define ULONGLONG_MAX ((unsigned long long)(~0ULL))
  641. #endif
  642. #endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/
  643.  
  644. #define INT_MIN32       (~0x7FFFFFFFL)
  645. #define INT_MAX32       0x7FFFFFFFL
  646. #define UINT_MAX32      0xFFFFFFFFL
  647. #define INT_MIN24       (~0x007FFFFF)
  648. #define INT_MAX24       0x007FFFFF
  649. #define UINT_MAX24      0x00FFFFFF
  650. #define INT_MIN16       (~0x7FFF)
  651. #define INT_MAX16       0x7FFF
  652. #define UINT_MAX16      0xFFFF
  653. #define INT_MIN8        (~0x7F)
  654. #define INT_MAX8        0x7F
  655.  
  656. /* From limits.h instead */
  657. #ifndef DBL_MIN
  658. #define DBL_MIN        4.94065645841246544e-324
  659. #define FLT_MIN        ((float)1.40129846432481707e-45)
  660. #endif
  661. #ifndef DBL_MAX
  662. #define DBL_MAX        1.79769313486231470e+308
  663. #define FLT_MAX        ((float)3.40282346638528860e+38)
  664. #endif
  665.  
  666. /*
  667.   Max size that must be added to a so that we know Size to make
  668.   adressable obj.
  669. */
  670. #if SIZEOF_CHARP == 4
  671. typedef long        my_ptrdiff_t;
  672. #else
  673. typedef long long    my_ptrdiff_t;
  674. #endif
  675.  
  676. #define MY_ALIGN(A,L)    (((A) + (L) - 1) & ~((L) - 1))
  677. #define ALIGN_SIZE(A)    MY_ALIGN((A),sizeof(double))
  678. /* Size to make adressable obj. */
  679. #define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
  680.              /* Offset of filed f in structure t */
  681. #define OFFSET(t, f)    ((size_t)(char *)&((t *)0)->f)
  682. #define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size)
  683. #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B))
  684.  
  685. #define NullS        (char *) 0
  686. /* Nowdays we do not support MessyDos */
  687. #ifndef NEAR
  688. #define NEAR                /* Who needs segments ? */
  689. #define FAR                /* On a good machine */
  690. #ifndef HUGE_PTR
  691. #define HUGE_PTR
  692. #endif
  693. #endif
  694. #if defined(__IBMC__) || defined(__IBMCPP__)
  695. #define STDCALL _System _Export
  696. #elif !defined( STDCALL)
  697. #define STDCALL
  698. #endif
  699.  
  700. /* Typdefs for easyier portability */
  701.  
  702. #if defined(VOIDTYPE)
  703. typedef void    *gptr;        /* Generic pointer */
  704. #else
  705. typedef char    *gptr;        /* Generic pointer */
  706. #endif
  707. #ifndef HAVE_INT_8_16_32
  708. typedef char    int8;        /* Signed integer >= 8    bits */
  709. typedef short    int16;        /* Signed integer >= 16 bits */
  710. #endif
  711. #ifndef HAVE_UCHAR
  712. typedef unsigned char    uchar;    /* Short for unsigned char */
  713. #endif
  714. typedef unsigned char    uint8;    /* Short for unsigned integer >= 8  bits */
  715. typedef unsigned short    uint16; /* Short for unsigned integer >= 16 bits */
  716.  
  717. #if SIZEOF_INT == 4
  718. #ifndef HAVE_INT_8_16_32
  719. typedef int        int32;
  720. #endif
  721. typedef unsigned int    uint32; /* Short for unsigned integer >= 32 bits */
  722. #elif SIZEOF_LONG == 4
  723. #ifndef HAVE_INT_8_16_32
  724. typedef long        int32;
  725. #endif
  726. typedef unsigned long    uint32; /* Short for unsigned integer >= 32 bits */
  727. #else
  728. error "Neither int or long is of 4 bytes width"
  729. #endif
  730.  
  731. #if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
  732. typedef unsigned long    ulong;          /* Short for unsigned long */
  733. #endif
  734. #ifndef longlong_defined
  735. #if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8
  736. typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
  737. typedef long long int    longlong;
  738. #else
  739. typedef unsigned long    ulonglong;      /* ulong or unsigned long long */
  740. typedef long        longlong;
  741. #endif
  742. #endif
  743.  
  744. /* typedef used for length of string;  Should be unsigned! */
  745. typedef ulong        size_str;
  746.  
  747. #ifdef USE_RAID
  748. /*
  749.   The following is done with a if to not get problems with pre-processors
  750.   with late define evaluation
  751. */
  752. #if SIZEOF_OFF_T == 4
  753. #define SYSTEM_SIZEOF_OFF_T 4
  754. #else
  755. #define SYSTEM_SIZEOF_OFF_T 8
  756. #endif
  757. #undef  SIZEOF_OFF_T
  758. #define SIZEOF_OFF_T        8
  759. #else
  760. #define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
  761. #endif /* USE_RAID */
  762.  
  763. #if SIZEOF_OFF_T > 4
  764. typedef ulonglong my_off_t;
  765. #else
  766. typedef unsigned long my_off_t;
  767. #endif
  768. #define MY_FILEPOS_ERROR    (~(my_off_t) 0)
  769. #if !defined(__WIN__) && !defined(OS2)
  770. typedef off_t os_off_t;
  771. #endif
  772.  
  773. #if defined(__WIN__)
  774. #define socket_errno    WSAGetLastError()
  775. #define SOCKET_EINTR    WSAEINTR
  776. #define SOCKET_EAGAIN    WSAEINPROGRESS
  777. #define SOCKET_EWOULDBLOCK WSAEINPROGRESS
  778. #define SOCKET_ENFILE    ENFILE
  779. #define SOCKET_EMFILE    EMFILE
  780. #elif defined(OS2)
  781. #define socket_errno    sock_errno()
  782. #define SOCKET_EINTR    SOCEINTR
  783. #define SOCKET_EAGAIN    SOCEINPROGRESS
  784. #define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
  785. #define SOCKET_ENFILE    SOCENFILE
  786. #define SOCKET_EMFILE    SOCEMFILE
  787. #define closesocket(A)    soclose(A)
  788. #else /* Unix */
  789. #define socket_errno    errno
  790. #define closesocket(A)    close(A)
  791. #define SOCKET_EINTR    EINTR
  792. #define SOCKET_EAGAIN    EAGAIN
  793. #define SOCKET_EWOULDBLOCK EWOULDBLOCK
  794. #define SOCKET_ENFILE    ENFILE
  795. #define SOCKET_EMFILE    EMFILE
  796. #endif
  797.  
  798. typedef uint8        int7;    /* Most effective integer 0 <= x <= 127 */
  799. typedef short        int15;    /* Most effective integer 0 <= x <= 32767 */
  800. typedef char        *my_string; /* String of characters */
  801. typedef unsigned long    size_s; /* Size of strings (In string-funcs) */
  802. typedef int        myf;    /* Type of MyFlags in my_funcs */
  803. #ifndef byte_defined
  804. typedef char        byte;    /* Smallest addressable unit */
  805. #endif
  806. typedef char        my_bool; /* Small bool */
  807. #if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
  808. typedef char        bool;    /* Ordinary boolean values 0 1 */
  809. #endif
  810.     /* Macros for converting *constants* to the right type */
  811. #define INT8(v)        (int8) (v)
  812. #define INT16(v)    (int16) (v)
  813. #define INT32(v)    (int32) (v)
  814. #define MYF(v)        (myf) (v)
  815.  
  816. #ifndef LL
  817. #ifdef HAVE_LONG_LONG
  818. #define LL(A) A ## LL
  819. #else
  820. #define LL(A) A ## L
  821. #endif
  822. #endif
  823.  
  824. /*
  825.   Defines to make it possible to prioritize register assignments. No
  826.   longer that important with modern compilers.
  827. */
  828. #ifndef USING_X
  829. #define reg1 register
  830. #define reg2 register
  831. #define reg3 register
  832. #define reg4 register
  833. #define reg5 register
  834. #define reg6 register
  835. #define reg7 register
  836. #define reg8 register
  837. #define reg9 register
  838. #define reg10 register
  839. #define reg11 register
  840. #define reg12 register
  841. #define reg13 register
  842. #define reg14 register
  843. #define reg15 register
  844. #define reg16 register
  845. #endif
  846.  
  847. /*
  848.   Sometimes we want to make sure that the variable is not put into
  849.   a register in debugging mode so we can see its value in the core
  850. */
  851.  
  852. #ifndef DBUG_OFF
  853. #define dbug_volatile volatile
  854. #else
  855. #define dbug_volatile
  856. #endif
  857.  
  858. /* Defines for time function */
  859. #define SCALE_SEC    100
  860. #define SCALE_USEC    10000
  861. #define MY_HOW_OFTEN_TO_ALARM    2    /* How often we want info on screen */
  862. #define MY_HOW_OFTEN_TO_WRITE    1000    /* How often we want info on screen */
  863.  
  864. #ifndef set_timespec
  865. #ifdef HAVE_TIMESPEC_TS_SEC
  866. #define set_timespec(ABSTIME,SEC) { (ABSTIME).ts_sec=time(0) + (time_t) (SEC); (ABSTIME).ts_nsec=0; }
  867. #else
  868. #define set_timespec(ABSTIME,SEC) \
  869. {\
  870.   struct timeval tv;\
  871.   gettimeofday(&tv,0);\
  872.   (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
  873.   (ABSTIME).tv_nsec=tv.tv_usec*1000;\
  874. }
  875. #endif /* HAVE_TIMESPEC_TS_SEC */
  876. #endif /* set_timespec */
  877.  
  878. /*
  879.   Define-funktions for reading and storing in machine independent format
  880.   (low byte first)
  881. */
  882.  
  883. /* Optimized store functions for Intel x86 */
  884. #if defined(__i386__) && !defined(_WIN64)
  885. #define sint2korr(A)    (*((int16 *) (A)))
  886. #define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
  887.                   (((uint32) 255L << 24) | \
  888.                    (((uint32) (uchar) (A)[2]) << 16) |\
  889.                    (((uint32) (uchar) (A)[1]) << 8) | \
  890.                    ((uint32) (uchar) (A)[0])) : \
  891.                   (((uint32) (uchar) (A)[2]) << 16) |\
  892.                   (((uint32) (uchar) (A)[1]) << 8) | \
  893.                   ((uint32) (uchar) (A)[0])))
  894. #define sint4korr(A)    (*((long *) (A)))
  895. #define uint2korr(A)    (*((uint16 *) (A)))
  896. #ifdef HAVE_purify
  897. #define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
  898.                   (((uint32) ((uchar) (A)[1])) << 8) +\
  899.                   (((uint32) ((uchar) (A)[2])) << 16))
  900. #else
  901. /*
  902.    ATTENTION !
  903.    
  904.     Please, note, uint3korr reads 4 bytes (not 3) !
  905.     It means, that you have to provide enough allocated space !
  906. */
  907. #define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
  908. #endif
  909. #define uint4korr(A)    (*((unsigned long *) (A)))
  910. #define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
  911.                     (((uint32) ((uchar) (A)[1])) << 8) +\
  912.                     (((uint32) ((uchar) (A)[2])) << 16) +\
  913.                     (((uint32) ((uchar) (A)[3])) << 24)) +\
  914.                      (((ulonglong) ((uchar) (A)[4])) << 32))
  915. #define uint8korr(A)    (*((ulonglong *) (A)))
  916. #define sint8korr(A)    (*((longlong *) (A)))
  917. #define int2store(T,A)    *((uint16*) (T))= (uint16) (A)
  918. #define int3store(T,A)        { *(T)=  (uchar) ((A));\
  919.                   *(T+1)=(uchar) (((uint) (A) >> 8));\
  920.                   *(T+2)=(uchar) (((A) >> 16)); }
  921. #define int4store(T,A)    *((long *) (T))= (long) (A)
  922. #define int5store(T,A)    { *(T)= (uchar)((A));\
  923.               *((T)+1)=(uchar) (((A) >> 8));\
  924.               *((T)+2)=(uchar) (((A) >> 16));\
  925.               *((T)+3)=(uchar) (((A) >> 24)); \
  926.               *((T)+4)=(uchar) (((A) >> 32)); }
  927. #define int8store(T,A)    *((ulonglong *) (T))= (ulonglong) (A)
  928.  
  929. typedef union {
  930.   double v;
  931.   long m[2];
  932. } doubleget_union;
  933. #define doubleget(V,M)    \
  934. { doubleget_union _tmp; \
  935.   _tmp.m[0] = *((long*)(M)); \
  936.   _tmp.m[1] = *(((long*) (M))+1); \
  937.   (V) = _tmp.v; }
  938. #define doublestore(T,V) { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
  939.                *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; }
  940. #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
  941. #define float8get(V,M) doubleget((V),(M))
  942. #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
  943. #define float8store(V,M) doublestore((V),(M))
  944. #endif /* __i386__ */
  945.  
  946. #ifndef sint2korr
  947. #define sint2korr(A)    (int16) (((int16) ((uchar) (A)[0])) +\
  948.                  ((int16) ((int16) (A)[1]) << 8))
  949. #define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
  950.                   (((uint32) 255L << 24) | \
  951.                    (((uint32) (uchar) (A)[2]) << 16) |\
  952.                    (((uint32) (uchar) (A)[1]) << 8) | \
  953.                    ((uint32) (uchar) (A)[0])) : \
  954.                   (((uint32) (uchar) (A)[2]) << 16) |\
  955.                   (((uint32) (uchar) (A)[1]) << 8) | \
  956.                   ((uint32) (uchar) (A)[0])))
  957. #define sint4korr(A)    (int32) (((int32) ((uchar) (A)[0])) +\
  958.                 (((int32) ((uchar) (A)[1]) << 8)) +\
  959.                 (((int32) ((uchar) (A)[2]) << 16)) +\
  960.                 (((int32) ((int16) (A)[3]) << 24)))
  961. #define sint8korr(A)    (longlong) uint8korr(A)
  962. #define uint2korr(A)    (uint16) (((uint16) ((uchar) (A)[0])) +\
  963.                   ((uint16) ((uchar) (A)[1]) << 8))
  964. #define uint3korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
  965.                   (((uint32) ((uchar) (A)[1])) << 8) +\
  966.                   (((uint32) ((uchar) (A)[2])) << 16))
  967. #define uint4korr(A)    (uint32) (((uint32) ((uchar) (A)[0])) +\
  968.                   (((uint32) ((uchar) (A)[1])) << 8) +\
  969.                   (((uint32) ((uchar) (A)[2])) << 16) +\
  970.                   (((uint32) ((uchar) (A)[3])) << 24))
  971. #define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
  972.                     (((uint32) ((uchar) (A)[1])) << 8) +\
  973.                     (((uint32) ((uchar) (A)[2])) << 16) +\
  974.                     (((uint32) ((uchar) (A)[3])) << 24)) +\
  975.                      (((ulonglong) ((uchar) (A)[4])) << 32))
  976. #define uint8korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
  977.                     (((uint32) ((uchar) (A)[1])) << 8) +\
  978.                     (((uint32) ((uchar) (A)[2])) << 16) +\
  979.                     (((uint32) ((uchar) (A)[3])) << 24)) +\
  980.             (((ulonglong) (((uint32) ((uchar) (A)[4])) +\
  981.                     (((uint32) ((uchar) (A)[5])) << 8) +\
  982.                     (((uint32) ((uchar) (A)[6])) << 16) +\
  983.                     (((uint32) ((uchar) (A)[7])) << 24))) <<\
  984.                      32))
  985. #define int2store(T,A)        { uint def_temp= (uint) (A) ;\
  986.                   *((uchar*) (T))=  (uchar)(def_temp); \
  987.                   *((uchar*) (T+1))=(uchar)((def_temp >> 8)); }
  988. #define int3store(T,A)        { /*lint -save -e734 */\
  989.                   *((uchar*)(T))=(uchar) ((A));\
  990.                   *((uchar*) (T)+1)=(uchar) (((A) >> 8));\
  991.                   *((uchar*)(T)+2)=(uchar) (((A) >> 16)); \
  992.                   /*lint -restore */}
  993. #define int4store(T,A)        { *(T)=(char) ((A));\
  994.                   *((T)+1)=(char) (((A) >> 8));\
  995.                   *((T)+2)=(char) (((A) >> 16));\
  996.                   *((T)+3)=(char) (((A) >> 24)); }
  997. #define int5store(T,A)        { *(T)=((A));\
  998.                   *((T)+1)=(((A) >> 8));\
  999.                   *((T)+2)=(((A) >> 16));\
  1000.                   *((T)+3)=(((A) >> 24)); \
  1001.                   *((T)+4)=(((A) >> 32)); }
  1002. #define int8store(T,A)        { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \
  1003.                   int4store((T),def_temp); \
  1004.                   int4store((T+4),def_temp2); \
  1005.                 }
  1006. #ifdef WORDS_BIGENDIAN
  1007. #define float4store(T,A)    { *(T)= ((byte *) &A)[3];\
  1008.                               *((T)+1)=(char) ((byte *) &A)[2];\
  1009.                               *((T)+2)=(char) ((byte *) &A)[1];\
  1010.                               *((T)+3)=(char) ((byte *) &A)[0]; }
  1011.  
  1012. #define float4get(V,M)      { float def_temp;\
  1013.                               ((byte*) &def_temp)[0]=(M)[3];\
  1014.                               ((byte*) &def_temp)[1]=(M)[2];\
  1015.                               ((byte*) &def_temp)[2]=(M)[1];\
  1016.                               ((byte*) &def_temp)[3]=(M)[0];\
  1017.                               (V)=def_temp; }
  1018. #define float8store(T,V)    { *(T)= ((byte *) &V)[7];\
  1019.                               *((T)+1)=(char) ((byte *) &V)[6];\
  1020.                               *((T)+2)=(char) ((byte *) &V)[5];\
  1021.                               *((T)+3)=(char) ((byte *) &V)[4];\
  1022.                               *((T)+4)=(char) ((byte *) &V)[3];\
  1023.                               *((T)+5)=(char) ((byte *) &V)[2];\
  1024.                               *((T)+6)=(char) ((byte *) &V)[1];\
  1025.                               *((T)+7)=(char) ((byte *) &V)[0]; }
  1026.  
  1027. #define float8get(V,M)        { double def_temp;\
  1028.                               ((byte*) &def_temp)[0]=(M)[7];\
  1029.                               ((byte*) &def_temp)[1]=(M)[6];\
  1030.                               ((byte*) &def_temp)[2]=(M)[5];\
  1031.                               ((byte*) &def_temp)[3]=(M)[4];\
  1032.                               ((byte*) &def_temp)[4]=(M)[3];\
  1033.                               ((byte*) &def_temp)[5]=(M)[2];\
  1034.                               ((byte*) &def_temp)[6]=(M)[1];\
  1035.                               ((byte*) &def_temp)[7]=(M)[0];\
  1036.                   (V) = def_temp; }
  1037. #else
  1038. #define float4get(V,M)   memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float))
  1039. #define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float))
  1040.  
  1041. #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
  1042. #define doublestore(T,V)    { *(T)= ((byte *) &V)[4];\
  1043.                               *((T)+1)=(char) ((byte *) &V)[5];\
  1044.                               *((T)+2)=(char) ((byte *) &V)[6];\
  1045.                               *((T)+3)=(char) ((byte *) &V)[7];\
  1046.                               *((T)+4)=(char) ((byte *) &V)[0];\
  1047.                               *((T)+5)=(char) ((byte *) &V)[1];\
  1048.                               *((T)+6)=(char) ((byte *) &V)[2];\
  1049.                               *((T)+7)=(char) ((byte *) &V)[3]; }
  1050. #define doubleget(V,M) { double def_temp;\
  1051.                               ((byte*) &def_temp)[0]=(M)[4];\
  1052.                               ((byte*) &def_temp)[1]=(M)[5];\
  1053.                               ((byte*) &def_temp)[2]=(M)[6];\
  1054.                               ((byte*) &def_temp)[3]=(M)[7];\
  1055.                               ((byte*) &def_temp)[4]=(M)[0];\
  1056.                               ((byte*) &def_temp)[5]=(M)[1];\
  1057.                               ((byte*) &def_temp)[6]=(M)[2];\
  1058.                               ((byte*) &def_temp)[7]=(M)[3];\
  1059.                   (V) = def_temp; }
  1060. #endif /* __FLOAT_WORD_ORDER */
  1061.  
  1062. #define float8get(V,M)   doubleget((V),(M))
  1063. #define float8store(V,M) doublestore((V),(M))
  1064. #endif /* WORDS_BIGENDIAN */
  1065.  
  1066. #endif /* sint2korr */
  1067.  
  1068. /*
  1069.   Define-funktions for reading and storing in machine format from/to
  1070.   short/long to/from some place in memory V should be a (not
  1071.   register) variable, M is a pointer to byte
  1072. */
  1073.  
  1074. #ifdef WORDS_BIGENDIAN
  1075.  
  1076. #define ushortget(V,M)    { V = (uint16) (((uint16) ((uchar) (M)[1]))+\
  1077.                     ((uint16) ((uint16) (M)[0]) << 8)); }
  1078. #define shortget(V,M)    { V = (short) (((short) ((uchar) (M)[1]))+\
  1079.                        ((short) ((short) (M)[0]) << 8)); }
  1080. #define longget(V,M)    { int32 def_temp;\
  1081.               ((byte*) &def_temp)[0]=(M)[0];\
  1082.               ((byte*) &def_temp)[1]=(M)[1];\
  1083.               ((byte*) &def_temp)[2]=(M)[2];\
  1084.               ((byte*) &def_temp)[3]=(M)[3];\
  1085.                 (V)=def_temp; }
  1086. #define ulongget(V,M)    { uint32 def_temp;\
  1087.               ((byte*) &def_temp)[0]=(M)[0];\
  1088.               ((byte*) &def_temp)[1]=(M)[1];\
  1089.               ((byte*) &def_temp)[2]=(M)[2];\
  1090.               ((byte*) &def_temp)[3]=(M)[3];\
  1091.                 (V)=def_temp; }
  1092. #define shortstore(T,A) { uint def_temp=(uint) (A) ;\
  1093.               *(T+1)=(char)(def_temp); \
  1094.               *(T+0)=(char)(def_temp >> 8); }
  1095. #define longstore(T,A)    { *((T)+3)=((A));\
  1096.               *((T)+2)=(((A) >> 8));\
  1097.               *((T)+1)=(((A) >> 16));\
  1098.               *((T)+0)=(((A) >> 24)); }
  1099.  
  1100. #define doubleget(V,M)     memcpy((byte*) &V,(byte*) (M),sizeof(double))
  1101. #define doublestore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(double))
  1102. #define longlongget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(ulonglong))
  1103. #define longlongstore(T,V) memcpy((byte*) (T),(byte*) &V,sizeof(ulonglong))
  1104.  
  1105. #else
  1106.  
  1107. #define ushortget(V,M)    { V = uint2korr(M); }
  1108. #define shortget(V,M)    { V = sint2korr(M); }
  1109. #define longget(V,M)    { V = sint4korr(M); }
  1110. #define ulongget(V,M)   { V = uint4korr(M); }
  1111. #define shortstore(T,V) int2store(T,V)
  1112. #define longstore(T,V)    int4store(T,V)
  1113. #ifndef doubleget
  1114. #define doubleget(V,M)     memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double))
  1115. #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double))
  1116. #endif /* doubleget */
  1117. #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong))
  1118. #define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong))
  1119.  
  1120. #endif /* WORDS_BIGENDIAN */
  1121.  
  1122. /* sprintf does not always return the number of bytes :- */
  1123. #ifdef SPRINTF_RETURNS_INT
  1124. #define my_sprintf(buff,args) sprintf args
  1125. #else
  1126. #ifdef SPRINTF_RETURNS_PTR
  1127. #define my_sprintf(buff,args) ((int)(sprintf args - buff))
  1128. #else
  1129. #define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff))
  1130. #endif
  1131. #endif
  1132.  
  1133. #ifndef THREAD
  1134. #define thread_safe_increment(V,L) (V)++
  1135. #define thread_safe_add(V,C,L)     (V)+=(C)
  1136. #define thread_safe_sub(V,C,L)     (V)-=(C)
  1137. #define statistic_increment(V,L)   (V)++
  1138. #define statistic_add(V,C,L)       (V)+=(C)
  1139. #endif
  1140.  
  1141. #endif /* my_global_h */
  1142.